#include <iostream>
#include <string>

using namespace std;

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int t,n,a;
	cin >> t;
	while(t--){
		cin >> n >> a;
		int zeroL = 0,oneL = 0;
		int initoneL = 0;
		string s;
		cin >> s;
		int index = 0;
		bool f = true;
		while(index < n && f){
			if(s[index] == '0'){
				++zeroL;
				++index;
				while(index < n && s[index] == '0'){
					++zeroL;
					++index;
				}
				if(zeroL >= a+1){
					f = false;
					break;
				}else{
					zeroL = 0;
				}
			}else{
				++oneL;
				++index;
				++initoneL;
				while(index < n && s[index] == '1'){
					++oneL;
					++index;
					++initoneL;
				}
				if(oneL >= a){
					f = false;
					break;
				}else{
					oneL = 0;
				}
			}
		}
		if(!f){
			cout << n;
		}else{
			cout << initoneL;
		}
		if(t) cout << endl;
	}

	return 0;
}

